<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="stu" style="font-size: 500px; font-size: 180px; color: blue;text-align: center;line-height: 500px;">
			
		</div>
		<script type="text/javascript">
			var stus = ["唐僧","悟空","八戒","沙僧","小白龙"]
			var t;
			var b = false;//表示停止状态
			var n;
			
			function startGame(){
				if(stus.length == 0){
					alert("全部都被选择了")
					return;
				}
				
				
				n = parseInt(Math.random()*stus.length);
				document.getElementById("stu").innerText = stus[n];
				
				t = setTimeout("startGame()",10);
			}
			function stopGame(){
				clearTimeout(t);
				stus.splice(n,1);
			}
			document.onkeydown = function(){
				if(event.keyCode == 13){
					if(!b){
						startGame();
					}else{
						stopGame();	
					}
					b = !b
				}
			}
		</script>
	</body>
</html>
